﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="OrderBuySell.ascx.cs" Inherits="ERP.Modules.OrderBuySell" %>

<%-------------------------------%>
<ext:Hidden ID="FormatTypeSell" runat="server" />
<%--------------GridSell-----------------%>
<ext:Panel ID="PanelSell" runat="server" Layout="Fit" Border="False">
    <Content>
        <ext:GridPanel
            ID="grSell"
            runat="server"
            Cls="grid-double"
            EnableColumnMove="true"
            Border="False">
            <Store>
                <ext:Store
                    ID="StoreSell"
                    runat="server"
                    OnReadData="StoreSell_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model runat="server" IDProperty="Order_Sell_Id" GroupField="Customer_Type_Name">
                            <Fields>
                                <ext:ModelField Name="Order_Sell_Code" Type="String" />
                                <ext:ModelField Name="Customer_Name" Type="String" />
                                <ext:ModelField Name="Customer_Type_Name" Type="String" />
                                <ext:ModelField Name="Order_Sell_DateBegin" Type="Date" />
                                <ext:ModelField Name="FullName" Type="String" />
                                <ext:ModelField Name="DateTimeReview" Type="Date" />
                                <ext:ModelField Name="FullName_Review" Type="String" />
                                <ext:ModelField Name="Note" Type="String" />
                                <ext:ModelField Name="IsActive" Type="Boolean" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:RowNumbererColumn runat="server" Width="30" Align="Center" />
                    <ext:Column runat="server" Text="Mã phiếu mua hàng" Width="115" DataIndex="Order_Sell_Code"></ext:Column>
                    <ext:Column runat="server" Text="Tên khách hàng" Width="131" DataIndex="Customer_Name"></ext:Column>
                    <ext:Column runat="server" Text="Loại khách hàng" Width="102" DataIndex="Customer_Type_Name"></ext:Column>
                    <ext:DateColumn runat="server" Text="Ngày đặt hàng" Width="109" DataIndex="Order_Sell_DateBegin" Format="dd-MM-yyyy" Align="Center"></ext:DateColumn>
                    <ext:Column runat="server" Text="Người đặt hàng" Width="122" DataIndex="FullName"></ext:Column>
                    <ext:DateColumn runat="server" Text="Ngày xét duyệt" Width="102" DataIndex="DateTimeReview" Format="dd-MM-yyyy" Align="Center"></ext:DateColumn>
                    <ext:Column runat="server" Text="NV xét duyệt" Width="133" DataIndex="FullName_Review"></ext:Column>
                    <ext:CheckColumn runat="server" Text="Trạng thái" Width="102" DataIndex="IsActive" Align="Center"></ext:CheckColumn>
                    <ext:Column runat="server" Text="Lý do" Width="133" DataIndex="Note" Flex="1"></ext:Column>
                </Columns>
            </ColumnModel>
            <Features>
                <ext:Grouping
                    runat="server" 
                    HideGroupedHeader="true"
                    GroupByText="Xem theo phân nhóm"
                    ShowGroupsText="Phân nhóm"
                    GroupHeaderTplString="{name} ({rows.length} danh mục con {[values.rows.length > 1 ? '' : '']})"
                    StartCollapsed="True" />
            </Features>
            <DirectEvents>
                <ItemDblClick OnEvent="SellDblClick">
                    <ExtraParams>
                        <ext:Parameter Name="Order_Sell_Id" Value="record.data.Order_Sell_Id" Mode="Raw" />
                    </ExtraParams>
                    <EventMask ShowMask="true" Msg="Đang tải..." />
                </ItemDblClick>
            </DirectEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel runat="server" Mode="Multi">
                    <Listeners>
                       <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnReview}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnReview}.enable();
                            }" />
                   </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <View>
                <ext:GridView runat="server" StripeRows="true" />
            </View>
            <DockedItems>
                <ext:Toolbar runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Thêm mới" Icon="ApplicationAdd">
                            <DirectEvents>
                                <Click OnEvent="btnAddNew_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnEdit" runat="server" Text="Sửa" Icon="ApplicationEdit">
                            <DirectEvents>
                                <Click OnEvent="btnEdit_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnReview" runat="server" Text="Xét duyệt" Icon="Tick" ToolTip="Check vào một phiếu đề nghị để xét duyệt">
                            <DirectEvents>
                                <Click OnEvent="btnReview_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grSell}, #{FormatTypeSell}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:DateField ID="txtDateBeginFillter" EmptyText="Từ ngày" runat="server" MarginSpec="0 8 0 0"/>
                        <ext:DateField ID="txtDateEndFillter" EmptyText="Đến ngày" runat="server" MarginSpec="0 5 0 0"/>
                        <ext:Button ID="btnFillter" runat="server" Text="Lọc" Icon="ApplicationGo" ToolTip="Chọn lọc theo ngày đặt hàng">
                            <DirectEvents>
                                <Click OnEvent="btnFillter_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:SelectBox
                            ID="SelectBoxReview"
                            runat="server"
                            Cls="x-select-box"
                            MarginSpec="0 8 0 0"
                            EmptyText="Chọn trạng thái">
                            <Items>
                                <ext:ListItem Value="1" Text="Đã duyệt"/>
                                <ext:ListItem Value="0" Text="Chưa duyệt"/>
                            </Items>
                            <DirectEvents>
                                <Select OnEvent="SelectBoxReview_Change">
                                    <EventMask ShowMask="true" Msg="Đang tải..."></EventMask>
                                </Select>
                            </DirectEvents>
                        </ext:SelectBox>
                    </Items>
                </ext:Toolbar>
                <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                                <TriggerClick OnEvent="Search_Event">
                                     <EventMask ShowMask="true" Msg="Đang tải..." />
                                </TriggerClick>
                                <SpecialKey OnEvent="Search_Event" Before="return e.getKey() == Ext.EventObject.ENTER;">
                                     <EventMask ShowMask="true" Msg="Đang tải..." />
                                </SpecialKey>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:PagingToolbar runat="server" StoreID="StoreSell" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
<ext:Panel runat="server">
    <Content>
        <%-----------WindowsOrderSell-----------------%>
        <ext:Window ID="WindowsOrderSell" runat="server"
            Title="Cập nhật đơn đặt hàng"
            Width="975"
            Height="534"
            Hidden="true"
            Region="Center"
            Modal="true"
            HideMode="Display"
            Border="false"
            Padding="5"
            DefaultButton="btnSavePopUp"
            Resizable="False">
            <Items>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Lưu lại" Icon="Disk" ID="btnSavePopUp">
                            <DirectEvents>
                                <Click OnEvent="btnSavePopUp_Click" Before="return #{FormPanelOrderSell}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="grOrderSell_Detail" Value="Ext.encode(#{grOrderSell_Detail}.getRowsValues({selectedOnly : false}))" Mode="Raw" />
                                    </ExtraParams>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Thêm vật tư" Icon="Add" ID="btnAddMaterial" MarginSpec="0 8 0 0">
                            <DirectEvents>
                                <Click OnEvent="btnAddMaterial_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Xoá vật tư" Icon="Cancel" ID="btnDelMaterial" MarginSpec="0 8 0 0">
                            <DirectEvents>
                                <Click OnEvent="btnDelMaterial_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá vật tư này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Huỷ bỏ" Icon="Decline" ID="btnCancelPopUp">
                            <DirectEvents>
                                <Click OnEvent="btnCancelPopUp_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:TextField ID="txtOrderSell_ID" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                        <ext:TextField ID="txtIsActive" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                    </Items>
                </ext:Toolbar>
                <ext:Panel
                    runat="server" 
                    Layout="ColumnLayout">
                     <Items>
                         <ext:Panel
                            runat="server" 
                            Width="218"
                            Frame="True"
                            MarginSpec="0 5 0 0"
                            Height="520">
                            <Items>
                                <ext:FormPanel ID="FormPanelOrderSell" runat="server"
                                    AutoHeight="true"
                                    BodyPadding="4"
                                    Frame="true"
                                    DefaultAnchor="100%">
                                    <Items>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Mã đơn hàng" />
                                        <ext:FieldContainer
                                                runat="server"
                                                AnchorHorizontal="100%"
                                                Layout="HBoxLayout">
                                                <Items>
                                                    <ext:TextField ID="txtOrderSellCode" runat="server" AllowBlank="False" Width="165" Margins="8 3 0 0" />
                                                    <ext:Button runat="server" Text="" Icon="Reload" ID="btnRefreshSellCode" ToolTip="Click vào để tải lại mã" Margins="8 3 0 0">
                                                        <DirectEvents>
                                                            <Click OnEvent="btnRefreshSellCode_Click">
                                                                <EventMask ShowMask="true" Msg="Đang tải..." />
                                                            </Click>
                                                        </DirectEvents>
                                                    </ext:Button>
                                                </Items>
                                            </ext:FieldContainer>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Ngày lập HĐ" Margins="8 3 0 0" />
                                        <ext:DateField ID="txtDateBegin" runat="server" AllowBlank="False" Width="250" MarginSpec="8 3 5 0" />
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Loại giá" Margins="8 3 0 0" Visible="False" />
                                        <ext:SelectBox
                                            ID="SelectType"
                                            runat="server"
                                            MarginSpec="8 8 8 0"
                                            AllowBlank="False"
                                            InputWidth="189"
                                            Visible="False"
                                            EmptyText="Chọn loại giá">
                                            <Items>
                                                <ext:ListItem Value="0" Text="Đơn giá bán lẽ"/>
                                                <ext:ListItem Value="1" Text="Đơn giá gốc"/>
                                            </Items>
                                             <DirectEvents>
                                                <Select OnEvent="SelectType_Change">
                                                    <EventMask ShowMask="true" Msg="Đang tải..."></EventMask>
                                                </Select>
                                            </DirectEvents>
                                        </ext:SelectBox>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Mã khách hàng" MarginSpec="8 3 8 0" />
                                        <ext:TextField ID="txtCustomerAlias" ReadOnly="True" AllowBlank="False" runat="server" Width="250" MarginSpec="8 3 8 0" />
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Tên khách hàng" MarginSpec="8 3 8 0" />
                                        <ext:FieldContainer
                                            runat="server"
                                            AnchorHorizontal="100%"
                                            Layout="HBoxLayout">
                                            <Items>
                                                <ext:TextField ID="txtCustomerName" ReadOnly="True" Width="162" AllowBlank="False" runat="server" MarginSpec="8 3 0 0" />
                                                <ext:Button runat="server" Text="" Icon="BulletGet" ID="btnAddCustomer" ToolTip="Đến danh sách" MarginSpec="8 3 0 0">
                                                     <DirectEvents>
                                                        <Click OnEvent="btnAddCustomer_Click">
                                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                                        </Click>
                                                    </DirectEvents>
                                                </ext:Button>
                                                <ext:Hidden runat="server" ID="txtCustomerID" AllowBlank="False"></ext:Hidden>
                                            </Items>
                                        </ext:FieldContainer>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Mã số thuế" Margins="0 3 8 0" />
                                        <ext:TextField ID="txtTaxCode" runat="server" ReadOnly="True" AnchorHorizontal="100%" MarginSpec="5 0 0 0" />
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Địa chỉ" MarginSpec="0 3 8 0" />
                                        <ext:TextField ID="txtCustomerAddress" ReadOnly="True" runat="server" AnchorHorizontal="100%" MarginSpec="5 0 0 0" />
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Ghi chú" MarginSpec="0 3 8 0" />
                                        <ext:TextArea ID="txtNote" runat="server" AnchorHorizontal="100%" Height="30" MarginSpec="5 0 0 0"/>
                                    </Items>
                                </ext:FormPanel>
                            </Items>
                         </ext:Panel>
                         <ext:Panel
                            runat="server" 
                            Width="736"
                            Layout="Fit" 
                            Border="False"
                            Height="410">
                             <Items>
                                 <ext:GridPanel
                                    ID="grOrderSell_Detail"
                                    Cls="grid-double"
                                    runat="server"
                                    EnableColumnMove="true"
                                    AutoWidth="true"
                                    AutoScroll="true"
                                    Layout="Fit"
                                    Height="195">
                                    <Store>
                                        <ext:Store
                                            ID="StoreOrderSell_Detail"
                                            runat="server"
                                            OnReadData="StoreOrderSell_Detail_RefreshData">
                                            <Model>
                                                <ext:Model runat="server" IDProperty="Order_Sell_Detail_Id">
                                                    <Fields>
                                                        <ext:ModelField Name="Order_Sell_Id" Type="Int" />
                                                        <ext:ModelField Name="Materials_Id" Type="Int" />
                                                        <ext:ModelField Name="Materials_Alias" Type="String" />
                                                        <ext:ModelField Name="Materials_Name" Type="String" />
                                                        <ext:ModelField Name="Unit_Name" Type="String" />
                                                        <ext:ModelField Name="Order_Detail_Quality" Type="Int" />
                                                        <ext:ModelField Name="Order_Detail_Price" Type="Float" />
                                                        <ext:ModelField Name="Price_Initially" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_CK_Percent" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_CK" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_VAT_Percent" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_VAT" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_Total_Price" Type="Float" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                    <ColumnModel runat="server">
                                        <Columns>
                                            <ext:RowNumbererColumn Text="STT" runat="server" Width="30" Align="Center" />
                                            <ext:Column runat="server" Text="Mã hàng" Width="100" DataIndex="Materials_Alias" />
                                            <ext:Column runat="server" Text="Tên hàng" Width="100" DataIndex="Materials_Name" />
                                            <ext:Column runat="server" Text="Đơn vị tính" Width="90" DataIndex="Unit_Name" />
                                            <ext:Column runat="server" Text="SL đề nghị" Width="90" DataIndex="Order_Detail_Quality">
                                                <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:Column ID="clOrder_Detail_Price" runat="server" AllowBlank="false" MinValue="0" Text="Giá bán lẽ" Width="100" DataIndex="Order_Detail_Price">
                                                 <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                                <Renderer Fn="Ext.util.Format.numberRenderer('0,000')" />
                                            </ext:Column>
                                            <ext:NumberColumn ID="clPrice_Initially" runat="server" Text="Giá gốc" Hidden="True" Width="90" DataIndex="Price_Initially" Format="0,00" />
                                            <ext:NumberColumn runat="server" Text="Tiền CK" Width="90" DataIndex="Order_Detail_CK" Format="0,00" />
                                            <ext:Column runat="server" Text="CK %" Width="90" DataIndex="Order_Detail_CK_Percent">
                                                 <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:NumberColumn runat="server" Text="Tiền VAT" Width="90" DataIndex="Order_Detail_VAT" Format="0,00" />
                                            <ext:Column runat="server" Text="VAT %" Width="90" DataIndex="Order_Detail_VAT_Percent">
                                                <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:NumberColumn runat="server" Text="Thành tiền" Width="90" DataIndex="Order_Detail_Total_Price" Format="0,00" /> 
                                        </Columns>
                                    </ColumnModel>
                                    <Plugins>
                                        <ext:RowEditing runat="server" SaveBtnText="Cập nhật" CancelBtnText="Hủy bỏ">
                                            <DirectEvents>
                                                <Edit OnEvent="UpdateMaterials_Click">
                                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                                    <ExtraParams>
                                                        <ext:Parameter Name="grOrderSell_Detail" Value="Ext.encode(#{grOrderSell_Detail}.getRowsValues({selectedOnly : true}))" Mode="Raw" />
                                                    </ExtraParams>
                                                </Edit>
                                            </DirectEvents>
                                        </ext:RowEditing>
                                    </Plugins>
                                    <SelectionModel>
                                        <ext:CheckboxSelectionModel runat="server" Mode="Multi" />
                                    </SelectionModel>
                                    <DockedItems>
                                        <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                                            <Items>
                                                <ext:PagingToolbar runat="server" StoreID="StoreOrderSell_Detail" EmptyMsg="Không có dữ liệu" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                                            </Items>
                                        </ext:Toolbar>
                                    </DockedItems>
                                </ext:GridPanel>
                             </Items>
                         </ext:Panel>
                         <ext:Panel
                            runat="server" 
                            Width="736"
                            MarginSpec="5 0 0 0"
                            Border="True"
                            Frame="True"
                            Height="56">
                             <Items>
                                 <ext:FieldContainer
                                    runat="server"
                                    AnchorHorizontal="100%">
                                    <Items>
                                        <ext:Label runat="server" Text="Tổng số lượng vật tư:" MarginSpec="0 8 8 0"></ext:Label>
                                        <ext:Label ID="lbQualityOrderSell" Cls="x-label-right-cost" runat="server" Text="0" Width="80"></ext:Label>
                                    
                                        <ext:Label runat="server" Text="Tổng đơn giá:" MarginSpec="0 8 8 0"></ext:Label>
                                        <ext:Label ID="lbPriceOrderSell" Cls="x-label-right-cost" runat="server" Text="0" Width="80"></ext:Label>

                                        <ext:Label runat="server" Text="Tổng tiền CK:" MarginSpec="0 8 8 0"></ext:Label>
                                        <ext:Label ID="lbPriCKOrderSell" Cls="x-label-right-cost" runat="server" Text="0" Width="80"></ext:Label>

                                        <ext:Label runat="server" Text="Tổng tiền VAT:" MarginSpec="0 8 8 0"></ext:Label>
                                        <ext:Label ID="lbPriVATOrderSell" Cls="x-label-right-cost" runat="server" Text="0" Width="80"></ext:Label>
                                    </Items>
                                </ext:FieldContainer>
                                 <ext:FieldContainer
                                    runat="server"
                                    AnchorHorizontal="100%">
                                    <Items>
                                        <ext:Label ID="Label1" runat="server" Text="Tổng tiền các mặt hàng bao gồm CK và VAT:" MarginSpec="0 8 8 0"></ext:Label>
                                        <ext:Label ID="lbTotalCostOrderSell" Cls="x-label-right-cost" runat="server" Text="0"></ext:Label>
                                    </Items>
                                </ext:FieldContainer>
                             </Items>
                         </ext:Panel>
                     </Items>
                 </ext:Panel>
            </Items>
        </ext:Window>
        <%--------------Material-----------------%>
        <ext:Window ID="WindowOrderSell_Proposed_Materials" runat="server"
            Title="Thông tin vật tư"
            DefaultAnchor="100%"
            Width="829"
            Height="400"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="False"
            Modal="true"
            Layout="Fit"
            HideMode="Offsets"
            Constrain="True">
            <Content>
                <ext:GridPanel
                    ID="grOrderSell_Proposed_Materials"
                    Border="True"
                    runat="server"
                    AutoWidth="true"
                    AutoScroll="true"
                    Cls="gird"
                    EnableColumnMove="true">
                    <Store>
                        <ext:Store
                            ID="StoreOrderSell_Proposed_Materials"
                            runat="server"
                            OnReadData="StoreOrderSell_Proposed_Materials_RefreshData"
                            PageSize="14">
                            <Model>
                                <ext:Model runat="server" IDProperty="Materials_Id">
                                    <Fields>
                                        <ext:ModelField Name="Materials_Id" Type="Int" />
                                        <ext:ModelField Name="Materials_Alias" Type="String" />
                                        <ext:ModelField Name="Materials_Name" Type="String" />
                                        <ext:ModelField Name="Materials_Type_Name" Type="String" />
                                        <ext:ModelField Name="Quality_Current" Type="Int" />
                                        <ext:ModelField Name="Quality_Initially" Type="Int" />
                                        <ext:ModelField Name="Price_Initially" Type="Float" />
                                        <ext:ModelField Name="Unit_Name" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:RowNumbererColumn runat="server" Width="30" Align="Center" />
                            <ext:Column runat="server" Text="Mã vật tư" Width="100" DataIndex="Materials_Alias" Align="Left"></ext:Column>
                            <ext:Column runat="server" Text="Tên vật tư" Width="100" DataIndex="Materials_Name" Align="Left"></ext:Column>
                            <ext:Column runat="server" Text="Nhóm vật tư" Width="100" DataIndex="Materials_Type_Name" Align="Left"></ext:Column>
                            <ext:Column runat="server" Text="SL ban đầu" Width="150" DataIndex="Quality_Current" Align="Center" Visible="False"></ext:Column>
                            <ext:Column runat="server" Text="SL còn lại" Width="150" DataIndex="Quality_Initially" Align="Center" Visible="False"></ext:Column>
                            <ext:Column runat="server" Text="Đơn vị tính" Width="50" DataIndex="Unit_Name" Align="Center" Flex="1"></ext:Column>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:CheckboxSelectionModel runat="server" Mode="Multi" />
                    </SelectionModel>
                    <TopBar>
                        <ext:Toolbar runat="server">
                            <Items>
                                <ext:Button ID="btnSelectOrderSell_Proposed_Materials" runat="server" Text="Chọn vật tư" Icon="Accept" ToolTip="Chọn vật tư">
                                    <DirectEvents>
                                        <Click OnEvent="btnSelectOrderSell_Proposed_Materials_Click">
                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <DockedItems>
                        <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                            <Items>
                                <ext:PagingToolbar runat="server" StoreID="StoreOrderSell_Proposed_Materials" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                            </Items>
                        </ext:Toolbar>
                    </DockedItems>
                </ext:GridPanel>
            </Content>
        </ext:Window>
        <%--------------Customer-----------------%>
        <ext:Window ID="WindowCustomerSell" runat="server"
            Title="Thông tin khách hàng"
            DefaultAnchor="100%"
            Width="829"
            Height="400"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="False"
            Modal="true"
            Layout="Fit"
            HideMode="Offsets"
            Constrain="True">
            <Content>
                <ext:GridPanel
                    ID="grCustomerSell"
                    Border="True"
                    runat="server"
                    AutoWidth="true"
                    AutoScroll="true"
                    Cls="gird"
                    EnableColumnMove="true">
                    <Store>
                        <ext:Store
                            ID="StoreCustomerSell"
                            runat="server"
                            OnReadData="StoreOrderCustomerSell_Proposed_Materials_RefreshData"
                            PageSize="14">
                            <Model>
                                <ext:Model runat="server" IDProperty="Customer_ID">
                                    <Fields>
                                        <ext:ModelField Name="Customer_ID" Type="Int" />
                                        <ext:ModelField Name="Customer_Alias" Type="String" />
                                        <ext:ModelField Name="Customer_Name" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:RowNumbererColumn runat="server" Width="30" Align="Center" />
                            <ext:Column runat="server" Text="Mã khách hàng" Width="100" DataIndex="Customer_Alias" Align="Left"></ext:Column>
                            <ext:Column runat="server" Text="Tên khách hàng" Width="100" DataIndex="Customer_Name" Align="Left" Flex="1"></ext:Column>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:CellSelectionModel runat="server">
                            <DirectEvents>
                                <Select OnEvent="CellOrderSellCustomer_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Select>
                            </DirectEvents>
                        </ext:CellSelectionModel>
                    </SelectionModel>
                    <DockedItems>
                        <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                            <Items>
                                <ext:PagingToolbar runat="server" StoreID="StoreCustomerSell" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                            </Items>
                        </ext:Toolbar>
                    </DockedItems>
                </ext:GridPanel>
            </Content>
        </ext:Window>
        <%----------------WindowsOrderReview-----------------%>
        <ext:Window ID="WindowOrderSellReview" runat="server"
            Title="Xét duyệt đơn bán hàng"
            DefaultAnchor="100%"
            Width="829"
            Height="605"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="false"
            Modal="true"
            HideMode="Offsets">
            <Content>
                <ext:Panel
                    runat="server"
                    Cls="width"
                    Layout="Fit"
                    Dock="Top"
                    ButtonAlign="Left"
                    AutoScroll="true">
                    <DockedItems>
                        <ext:Toolbar runat="server" Dock="Top">
                            <Items>
                                <ext:Button ID="btnReviewWindow" runat="server" Text="Xét duyệt" Icon="Tick" ToolTip="Xét duyệt mẫu tin">
                                    <DirectEvents>
                                        <Click OnEvent="btnReviewWindow_Click">
                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                            <Confirmation ConfirmRequest="true"
                                                Title="Thông Báo" Message="Bạn có muốn xét duyệt đơn đặt hàng này không ?">
                                            </Confirmation>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:ToolbarSeparator />
                                <ext:Button ID="btnUnReviewWindow" runat="server" Text="Bỏ xét duyệt" Icon="Cross" ToolTip="Huỷ xét duyệt mẫu tin">
                                    <DirectEvents>
                                        <Click OnEvent="btnUnReviewWindow_Click">
                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                            <Confirmation ConfirmRequest="true"
                                                 Title="Thông Báo" Message="Bạn có muốn huỷ xét duyệt đơn đặt hàng này không ?">
                                            </Confirmation>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:ToolbarSeparator />
                                <ext:Button ID="btnReLoadReviewOrder" runat="server" Text="Tải lại" Icon="Reload" ToolTip="Làm tươi">
                                    <DirectEvents>
                                        <Click OnEvent="btnReLoadReviewOrder_Click">
                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:ToolbarSeparator Visible="False" />
                                <ext:Button ID="btnPrintReviewOrder" runat="server" Text="Cập nhật lý do" Icon="BookAddressesEdit" ToolTip="In đơn mua hàng" OnClientClick=" window.print(); " Visible="False"></ext:Button>
                                <ext:ToolbarSeparator />
                                <ext:Button ID="btnExitReviewOrder" runat="server" Text="Đóng lại" Icon="Cancel" ToolTip="Đóng cửa sổ xét duyệt">
                                    <DirectEvents>
                                        <Click OnEvent="btnExitReviewOrder_Click">
                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:TextField ID="txtReviewOrder_Sell_Id" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                            </Items>
                        </ext:Toolbar>
                    </DockedItems>
                </ext:Panel>
                <ext:FormPanel
                    runat="server"
                    Width="817"
                    Height="569"
                    Border="false"
                    Frame="true"
                    DefaultAnchor="100%">
                    <Items>
                        <ext:FieldSet
                            runat="server"
                            Title="Thông tin khách hàng"
                            MarginSpec="0 8 0 0"
                            Padding="10"
                            Height="210px"
                            ButtonAlign="Right">
                            <Defaults>
                                <ext:Parameter Name="Width" Value="500" />
                                <ext:Parameter Name="LabelWidth" Value="90" />
                            </Defaults>
                            <Items>
                                <ext:Container runat="server" Layout="HBoxLayout">
                                    <Items>
                                        <ext:Label runat="server" Text="Mã khách hàng:" MarginSpec="0 8 15 0"></ext:Label>
                                        <ext:Label ID="lbReviewCustomer_Alias" Cls="x-label-right" runat="server" Text=""></ext:Label>

                                    </Items>
                                </ext:Container>

                                <ext:Container runat="server" Layout="HBoxLayout">
                                    <Items>
                                        <ext:Label runat="server" Text="Tên khách hàng:" MarginSpec="0 8 15 0"></ext:Label>
                                        <ext:Label ID="lbReviewCustomer_Name" Cls="x-label-right" runat="server" Text=""></ext:Label>
                                    </Items>
                                </ext:Container>

                                <ext:Container runat="server" Layout="HBoxLayout">
                                    <Items>
                                        <ext:Label runat="server" Text="Chứng từ đặt:" MarginSpec="0 8 15 0"></ext:Label>
                                        <ext:Label ID="lbReviewOrderCode" Cls="x-label-right" runat="server" Text=""></ext:Label>
                                    </Items>
                                </ext:Container>

                                <ext:Container runat="server" Layout="HBoxLayout">
                                    <Items>
                                        <ext:Label runat="server" Text="Ngày đặt hàng:" MarginSpec="0 8 15 0"></ext:Label>
                                        <ext:Label ID="lbReviewOrderDate" Cls="x-label-right" runat="server" Text=""></ext:Label>
                                    </Items>
                                </ext:Container>

                                <ext:Container runat="server" Layout="HBoxLayout">
                                    <Items>
                                        <ext:Label runat="server" Text="Ngày duyệt/huỷ:" MarginSpec="0 8 15 0"></ext:Label>
                                        <ext:Label ID="lbReviewDateUpdate" Cls="x-label-right" runat="server" Text=""></ext:Label>
                                    </Items>
                                </ext:Container>

                                <ext:Container runat="server" Layout="HBoxLayout">
                                    <Items>
                                        <ext:Label runat="server" Text="Thời gian duyệt/huỷ vào lúc:" MarginSpec="0 8 15 0"></ext:Label>
                                        <ext:Label ID="lbReViewTime" Cls="x-label-right" runat="server" Text=""></ext:Label>
                                    </Items>
                                </ext:Container>
                            </Items>
                        </ext:FieldSet>
                        <ext:FieldSet
                            runat="server"
                            Title="Thông tin vật tư"
                            MarginSpec="0 8 0 0"
                            Padding="10"
                            Layout="Fit"
                            ButtonAlign="Right">
                            <Items>
                                <ext:GridPanel
                                    ID="grOrderSellReview"
                                    Border="True"
                                    runat="server"
                                    AutoWidth="true"
                                    AutoScroll="true"
                                    Cls="gird"
                                    Layout="Fit"
                                    EnableColumnMove="true"
                                    Height="240">
                                    <Store>
                                        <%-------------StoreOrderReview-----------------%>
                                        <ext:Store
                                            ID="StoreOrderSellReview"
                                            runat="server"
                                            OnReadData="StoreOrderSellReview_RefreshData"
                                            PageSize="10">
                                            <Model>
                                                <ext:Model runat="server" IDProperty="Order_Sell_Detail_Id">
                                                    <Fields>
                                                        <ext:ModelField Name="Order_Sell_Id" Type="Int" />
                                                        <ext:ModelField Name="Materials_Id" Type="Int" />
                                                        <ext:ModelField Name="Materials_Name" Type="String" />
                                                        <ext:ModelField Name="Order_Detail_Quality" Type="Int" />
                                                        <ext:ModelField Name="Order_Detail_Price" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_CK_Percent" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_CK" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_VAT_Percent" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_VAT" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_Total_Price" Type="Float" />
                                                        <ext:ModelField Name="IsActive" Type="Boolean" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                    <ColumnModel runat="server">
                                        <Columns>
                                            <ext:RowNumbererColumn Text="STT" runat="server" Width="30" Align="Center" />
                                            <ext:Column runat="server" Text="Tên vật tư" Width="100" DataIndex="Materials_Name" Align="Left"></ext:Column>
                                            <ext:Column runat="server" Text="SL đề nghị" Width="90" DataIndex="Order_Detail_Quality">
                                                <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:Column runat="server" AllowBlank="false" MinValue="0" Text="Đơn giá" Width="100" DataIndex="Order_Detail_Price">
                                                 <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                                <Renderer Fn="Ext.util.Format.numberRenderer('0,000')" />
                                            </ext:Column>
                                            <ext:Column runat="server" Text="CK %" Width="90" DataIndex="Order_Detail_CK_Percent">
                                                 <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:NumberColumn runat="server" Text="Tiền CK" Width="75" DataIndex="Order_Detail_CK" Format="0,00" Align="Center"></ext:NumberColumn>
                                            <ext:Column runat="server" Text="VAT %" Width="90" DataIndex="Order_Detail_VAT_Percent">
                                                <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:NumberColumn runat="server" Text="Tiền VAT" Width="75" DataIndex="Order_Detail_VAT" Format="0,00" Align="Center"></ext:NumberColumn>
                                            <ext:NumberColumn runat="server" Text="Tổng tiền" Width="75" Flex="1" DataIndex="Order_Detail_Total_Price" Format="0,00" Align="Center" CustomSummaryType="totalCost"></ext:NumberColumn>
                                            <ext:CheckColumn runat="server" Text="Trạng thái" Width="102" DataIndex="IsActive" Align="Center"></ext:CheckColumn>
                                        </Columns>
                                    </ColumnModel>
                                    <Plugins>
                                        <ext:RowEditing runat="server" SaveBtnText="Cập nhật" CancelBtnText="Hủy bỏ">
                                            <DirectEvents>
                                                <Edit OnEvent="UpdateReview_Click">
                                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                                    <ExtraParams>
                                                        <ext:Parameter Name="grOrderSellReview" Value="Ext.encode(#{grOrderSellReview}.getRowsValues({selectedOnly : true}))" Mode="Raw" />
                                                    </ExtraParams>
                                                </Edit>
                                            </DirectEvents>
                                        </ext:RowEditing>
                                    </Plugins>
                                    <SelectionModel>
                                        <ext:CheckboxSelectionModel runat="server" Mode="Multi" />
                                    </SelectionModel>
                                    <BottomBar>
                                        <ext:PagingToolbar runat="server" StoreID="StoreOrderSellReview" EmptyMsg="Không có dữ liệu" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                                    </BottomBar>
                                </ext:GridPanel>
                                <ext:Hidden ID="HdCustomer_Id" runat="server"></ext:Hidden>
                                <ext:Hidden ID="HdReviewOrderSell_Id" runat="server"></ext:Hidden>
                                <ext:Hidden ID="HdReviewIsActive" runat="server"></ext:Hidden>
                            </Items>
                        </ext:FieldSet>
                        <ext:FieldSet
                            runat="server"
                            Title="Tổng tiền các mặt hàng"
                            MarginSpec="0 8 0 0"
                            Padding="10"
                            Layout="Fit"
                            ButtonAlign="Right">
                            <Items>
                                <ext:Container runat="server" Layout="HBoxLayout">
                                    <Items>
                                        <ext:Label runat="server" Text="Tổng tiền các mặt hàng:" MarginSpec="0 8 8 0"></ext:Label>
                                        <ext:Label ID="lbTotalMaterialReview" Cls="x-label-right-cost" runat="server" Text=""></ext:Label>
                                    </Items>
                                </ext:Container>
                            </Items>
                        </ext:FieldSet>
                    </Items>
                </ext:FormPanel>
            </Content>
        </ext:Window>
    </Content>
</ext:Panel>